#ifndef SERVER_H
#define SERVER_H

#include <QDialog>

#include <QtGui>
#include <QtNetwork>

#include <vector>
#include "funcoes.h"
#include "modbus.h"
#include "db.h" 
#include "wells.h"
#include "deamon.h"
#include <stdlib.h>

QT_BEGIN_NAMESPACE
class QLabel;
class QPushButton;
class QTcpServer;
QT_END_NAMESPACE


struct simuladores{
	int id;
	QString name;
	QString ip;
	ModbusMestre *M;
};

class Server : public QDialog
{
Q_OBJECT

public:
	Server(QWidget *parent = 0);
	static std::map<int,SocketClient *> sVector;
	static std::map<int,simuladores> sMap;
	static std::map<QString,wells> wMap;
	static pthread_mutex_t mutex;

private slots:
	void acceptNewConnection();
	void deleteSocket();
	void readData();
	void readDataSlot();

private:
	void setStats();
	deamon *d;
	int numberOfConnections;
	QLabel *statusLabel;
	QPushButton *quitButton;
	QTcpServer *tcpServer;
	quint16 blockSize;
};
#endif
